/*
 * @Author: sikonggpw 1327325804@qq.com
 * @Date: 2023-02-20 15:36:37
 * @LastEditors: sikonggpw 1327325804@qq.com
 * @LastEditTime: 2023-02-22 14:31:36
 * @FilePath: \spider-node\sql.js
 * @Description: 连接数据库（老式）
 */
const mysql = require('mysql');

const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: '',
  database: 'user'
});

connection.connect((err) => {
  if (err) throw err;
  console.log('Connected!');
});

connection.query('SELECT * FROM username', (error, results, fields) => {
  if (error) {
    console.log('qwqwqw');
    throw error;
  }
  console.log(results);
});
